package com.example.swagger2.dto;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class ReqDTO extends Command {
    @ApiModelProperty(value = "调拨日期 (yyyy-MM-dd)", example = "2021-10-21", required = true)
    @NotNull(message = "日期不能为空")
    @DateTimeFormat(pattern = "yyy-MM-dd")
    private LocalDate day1;

    @ApiModelProperty(value = "站点属性 不传默认值是0")
//    @NotNull(message = "站点id不能为空")
    private Integer repoId = 0;

    @ApiModelProperty(value = "姓名", required = true)
    @NotEmpty(message = "name字段不能为空")
//    @NotNull
    private String name;

    @Valid
    @ApiModelProperty(value = "操作list", required = true)
//    @Size(min = 1, message = "list必须要有一个")
    @NotEmpty(message = "list不能为空")
    private List<ItemDTO> listItems;

    @Data
    @Accessors(chain = true)
    @ApiModel(value = "内部处理对象")
    public static class ItemDTO{
        @ApiModelProperty(value = "来源的站点id")
        @NotNull
        private Long srcRepoId;
        @ApiModelProperty(value = "来源的站点名称")
        @NotEmpty(message = "srcRepoName不能为空")
        private String srcRepoName;
    }
}
